﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/SiteContent.Master" AutoEventWireup="true" CodeBehind="MoveList.aspx.cs" Inherits="Warehouse.Web.Inventory.MoveList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .moduleheader .moduleheadertoolbar > * {
            margin: 16px 5px 0 5px;
        }
        .datatable {
            width: 100%;
        }
        .status_1 {
            color: Red;
        }
        .col-sn {
            width: 80px;
        }
        .col-tag {
            width: 80px;
        }
        .col-incomingdate {
            width: 70px;
        }
        .col-amount {
            width: 50px;
            text-align: right;
        }
        .col-bookkeeper {
            width: 60px;
        }
        .col-warehousekeeper {
            width: 60px;
        }
        .col-accepter {
            width: 60px;
        }
        .col-drawer {
            width: 60px;
        }
        .col-comments {
        }
    </style>

    <script type="text/javascript">
        var PRODUCTS = {};
        var PRODUCTSPECIFICATIONS = {};
        var WAREHOUSES = {};
        var SUPPLIERS = {};
        function showStock(stockId) {
            Util.get("", { action: 'GetStock', StockID: stockId }, function (succeed, data, err) {
                if (succeed) {
                    if (data) {
                        data.Stock._MovingDate = Util.parseDateTime(data.Stock.MovingDate);
                        data.Stock.MovingDate = Util.getDateString(data.Stock._MovingDate);
                        var html = '<div class="dialog">' + widgets.buildMoveStockTable(data.Stock, data.Details, WAREHOUSES[data.Stock.FromHouseID], WAREHOUSES[data.Stock.ToHouseID]) + '</div>';
                        var dialog = top.showDialog(html, { title: '移库单详情',
                            resizable: false,
                            modal: true,
                            width: 600,
                            buttons: {
                                "关闭": function () {
                                    dialog.dialog('close');
                                }
                            }
                        });
                    } else {
                        alert("未找到符合条件的移库单");
                    }
                } else {
                    alert(err);
                }
            }, { autoOverlay: true });
        }
        function search() {
            var fromHouseId = $("#sltFromHouse").val() - 0;
            var toHouseId = $("#sltToHouse").val() - 0;

            var startDate = $("#dtStart").val();
            var endDate = $("#dtEnd").val();
            Util.get("", { action: "Search", "FromHouseId": fromHouseId, "ToHouseId": toHouseId, "StartDate": startDate, "EndDate": endDate }, function (succeed, data, err) {
                if (succeed) {
                    if (data) {
                        var html = ['<table class="datatable">'];
                        html.push('<tr>');
                        html.push('<th class="col-sn">编号</th>');
                        html.push('<th class="col-tag">移出仓库</th>');
                        html.push('<th class="col-tag">移入仓库</th>');
                        html.push('<th class="col-incomingdate">移库日期</th>');
                        html.push('<th class="col-comments">备注</th>');
                        html.push('</tr>');
                        $.each(data, function () {
                            html.push('<tr class="status_0">');
                            html.push('<td class="col-sn"><a href="#" onclick="showStock(\'' + this.ID + '\')">' + this.SerialNumber + '</a></td>');
                            html.push('<td class="col-tag">' + this.FromHouse + '</td>');
                            html.push('<td class="col-tag">' + this.ToHouse + '</td>');
                            html.push('<td class="col-incomingdate">' + Util.getDateString(Util.parseDateTime(this.MovingDate)) + '</td>');
                            html.push('<td class="col-comments">' + this.Comments + '</td>');
                            html.push('</tr>');
                        });
                        html.push('</table>');

                        $('.modulecontent').html(html.join(''));
                    } else {
                        alert("未找到符合条件的入库单");
                    }
                } else {
                    alert(err);
                }
            }, { autoOverlay: true });
        }
        $(function () {
            $("#sltFromHouse").html('<option value="0">不限</option>');
            $("#sltToHouse").html('<option value="0">不限</option>');
            $.each(eval("(" + document.getElementById("allwarehouses").innerHTML + ")"), function () {
                WAREHOUSES[this.ID] = this;
                $("#sltFromHouse").html($("#sltFromHouse").html() + '<option value="' + this.ID + '">' + this.Name + '</option>');
                $("#sltToHouse").html($("#sltToHouse").html() + '<option value="' + this.ID + '">' + this.Name + '</option>');
            });
            var productnames = {};
            $.each(eval("(" + document.getElementById("allproducts").innerHTML + ")"), function () {
                PRODUCTS[this.ID] = this;
            });
            $.each(eval("(" + document.getElementById("allproductspecifications").innerHTML + ")"), function () {
                var p = PRODUCTS[this.ProductID];

                if (p) {
                    PRODUCTSPECIFICATIONS[this.ID] = this;
                    var item = { label: [p.Code || '', p.Name, p.Grade, p.Model, "[" + this.Specification + "]"].join(" "), value: [p.Name, p.Grade, p.Model].join(" "), Product: p, Specification: this };
                    productnames[this.ID] = item;
                }
            });
            $.each(eval("(" + document.getElementById("allsuppliers").innerHTML + ")"), function () {
                SUPPLIERS[this.ID] = this;
            });
            $(window.document.forms[0]).bind('submit', function (event) {
                event.preventDefault();
                search();
                return false;
            });
            $(".datepicker").datepicker({ dateFormat: 'yy-mm-dd' });
            //$("#dtEnd").datepicker({ dateFormat: 'yy-mm-dd' });
        });
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="moduleheader">
        <h4>
            移库单查询</h4>
        <div class="moduleheadertoolbar">
            <label>
                移出仓库：
                    <select id="sltFromHouse">
                    </select>
            </label>
            <label>
                移入仓库：
                    <select id="sltToHouse">
                    </select>
            </label>
            <label>
                移库日期：<input type="text" id="dtStart" readonly="readonly" class="datepicker" value="<%= DateTime.Now.Date.AddDays(1-DateTime.Now.Day).ToString("yyyy-MM-dd") %>" />—
                <input type="text" id="dtEnd" class="datepicker" readonly="readonly" value="<%= DateTime.Now.Date.ToString("yyyy-MM-dd") %>" />
            </label>
            <input type="button" class="ui-button-query" onclick="search();return false;" value="查询" />
        </div>
    </div>
    <div class="modulecontent">
    </div>
</asp:Content>

